﻿myApp.controller("LoginCtrl", ['$scope', '$post', '$http', '$routeParams', '$restUrls', '$rootScope', '$location', function ($scope, $post, $http, $routeParams, $restUrls, $rootScope, $location) {
    $('input').on('click', function (e) {
        var $this = $(this);
        e.preventDefault();
        setTimeout(function () {
            $(window).scrollTop($this.offset().top - 10);
        }, 200)
    });
    $scope.logining = false;
    $scope.Login = function (login) {
        if ($scope.logining) {
            return;
        }
        if (!$scope.LoginForm.$valid) {
            $scope.showOneError = true;
            return;
        }
        //var parameters = {
        //    telephone: login.telephone,
        //    password: login.password,
        //    firstname: userinfo.name,
        //    image: userinfo.image,
        //    open_id: userinfo.open_id
        //};
        var parameters = {
            telephone: login.telephone,
            password: login.password
        };
        $scope.logining = true;
        window.location.href = "#/bindchild";
        return;
        $post($restUrls["login"], parameters).success(function (result) {
            if (result.success == 1) {
                $scope.logining = false;
                window.location.href = "#/bindchild";
            }
            else {
                $scope.logining = false;
                $.scojs_message(result.message, $.scojs_message.TYPE_ERROR);
            }
        }).error(function (data, status, headers, config) {
            $scope.logining = false;
            $.scojs_message('服务器忙,请稍候重试', $.scojs_message.TYPE_ERROR);
        })
    }
}]);
